package com.norma.macaron.common.model.enums;

import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;


/**
 * @Author zhangchaofeng
 * @Date 16:15 2020/6/4 0004
 **/
@ToString
public enum AuthCode implements ResultCode {
    AUTH_USERNAME_NONE(23001, "请输入账号！"),
    AUTH_PASSWORD_NONE(23002, "请输入密码！"),
    AUTH_VERIFYCODE_NONE(23003, "请输入验证码！"),
    AUTH_ACCOUNT_NOTEXISTS(23004, "账号不存在！"),
    AUTH_CREDENTIAL_ERROR(23005, "账号或密码错误！"),
    AUTH_LOGIN_ERROR(23006, "登陆过程出现异常请尝试重新操作！"),
    AUTH_LOGIN_APPLYTOKEN_FAIL(23007, "申请令牌失败！"),
    AUTH_LOGIN_TOKEN_SAVEFAIL(23008, "存储令牌失败！"),
    AUTH_LOGOUT_FAIL(23009, "退出失败！");

    @ApiModelProperty(value = "操作代码", example = "22001", required = true)
    Integer code;

    @ApiModelProperty(value = "操作提示", example = "操作过于频繁！", required = true)
    String message;

    AuthCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private static final ImmutableMap<Integer, AuthCode> CACHE;

    static {
        final ImmutableMap.Builder<Integer, AuthCode> builder = ImmutableMap.builder();
        for (AuthCode commonCode : values()) {
            builder.put(commonCode.code(), commonCode);
        }
        CACHE = builder.build();
    }


    @Override
    public Integer code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
